//
//  ViewController.m
//  UI06_homework2
//
//  Created by aaaaaa on 16/6/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "CustomSmallScrollView.h"
#import "CustomBigScrollView.h"

@interface ViewController ()<UIScrollViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createScrollView];
}

- (void)createScrollView{
    UIImage *image1 = [UIImage imageNamed:@"cymbal_00.jpg"];
    CustomSmallScrollView *smallScroll1 = [[CustomSmallScrollView alloc] initWithFrame:CGRectMake(100, 100, 300, 500) withImage:image1];
    
    UIImage *image2 = [UIImage imageNamed:@"cymbal_01.jpg"];
    CustomSmallScrollView *smallScroll2 = [[CustomSmallScrollView alloc] initWithFrame:CGRectMake(100, 100, 300, 500) withImage:image2];
    
    UIImage *image3 = [UIImage imageNamed:@"cymbal_02.jpg"];
    CustomSmallScrollView *smallScroll3 = [[CustomSmallScrollView alloc] initWithFrame:CGRectMake(100, 100, 300, 500) withImage:image3];
    
    NSArray *scrollArray = @[smallScroll1, smallScroll2,smallScroll3];
    [smallScroll1 release];
    [smallScroll2 release];
    [smallScroll3 release];

    CustomBigScrollView *bigScroll = [[CustomBigScrollView alloc] initWithFrame:CGRectMake(0, 0, 300, 500)];
    bigScroll.delegate = self;
    
    bigScroll.center = self.view.center;
    
    [bigScroll addScrollView:scrollArray];
    
    [self.view addSubview:bigScroll];
    [bigScroll release];
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

    for (CustomSmallScrollView *smallScroll in scrollView.subviews) {
        smallScroll.zoomScale = 1.0;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
